-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(migrate): add migration by type (csv, json, excel)
- Loading branch information
1 parent
dafa78d
commit 3012800
Showing
5 changed files
with
67 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pytest | ||
coverage | ||
python-decouple | ||
requests | ||
requests | ||
pandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name,country,city,address,zip,website,phone | ||
Politie Utrecht,Netherland,Utrecht,Marco Pololaan 215,3526GB,https://www.politie.nl/,0900-8844 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import unittest | ||
from unittest.mock import Mock, patch | ||
from hubmigrate.client import MigrationClient | ||
from ..classes.auth import Auth | ||
import pandas as pd | ||
import os | ||
|
||
|
||
class TestMigrateCompanyExcel(unittest.TestCase): | ||
@patch('hubmigrate.client.MigrationClient.migrate_company', return_value=Mock(status_code=200)) | ||
@patch('hubmigrate.classes.auth.Auth.get_token') | ||
def test_migrate_company(self, mock_auth, mock_post): | ||
# Create a test company | ||
# Get the path to the current directory of your test script | ||
current_dir = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
# Define the relative path to your JSON file from the current directory | ||
relative_path = '../sample_company.xlsx' | ||
|
||
# Construct the full file path | ||
excel_file_path = os.path.join(current_dir, relative_path) | ||
path = excel_file_path | ||
with open(path) as f: | ||
test_company = pd.read_excel(f) | ||
|
||
# Create an instance of the MigrationClient class | ||
client = MigrationClient('config', 'hubspot') | ||
|
||
# Call the migrate_company method | ||
result = client.migrate_company({'properties': test_company}, 'excel') | ||
|
||
# Assertions | ||
self.assertEqual(result.status_code, 200) |