def test_calls_the_original_function_twice_with_given_date( self, original_function): self.data_dict = { "package_id": "1234", "url": "valid-organogram.xlsx", "upload": create.FakeFieldStorage("valid-organogram.xlsx", open(self.fixture_path)), "datafile-date": "2019-05-23" } with patch("ckanext.datagovuk.action.create.get_action" ) as mock_get_action: mock_get_action.return_value = lambda *_args: self.pkg_dict create.resource_create(self.context, self.data_dict) self.assertEqual(len(original_function.call_args_list), 2) senior_args, _kwargs = original_function.call_args_list[0] self._assert_resource_created(senior_args, "Organogram (Senior)", "organogram-senior.csv", "2019-05-23") junior_args, _kwargs = original_function.call_args_list[1] self._assert_resource_created(junior_args, "Organogram (Junior)", "organogram-junior.csv", "2019-05-23")
def setUp(self): self.data_dict = { "package_id": "1234", "url": "valid-organogram.xls", "upload": create.FakeFieldStorage("valid-organogram.xls", open(self.fixture_path)) } self.pkg_dict = { "schema-vocabulary": "538b857a-64ba-490e-8440-0e32094a28a7", } super(self.__class__, self).setUp()
def setUp(self): fixture_path = os.path.join(os.path.dirname(__file__), "../data/sample-invalid-junior.xls") self.data_dict = { "package_id": "1234", "url": "invalid-organogram.xls", "upload": create.FakeFieldStorage("invalid-organogram.xls", open(fixture_path)) } self.pkg_dict = { "schema-vocabulary": "538b857a-64ba-490e-8440-0e32094a28a7", } super(self.__class__, self).setUp()
def setUp(self): file_stream = BytesIO("12345") file_stream.seek(3) self.field_storage = create.FakeFieldStorage("test_filename.txt", file_stream)