def test_start_one_day_single(self): jira = JiraHelper(None, None, None, False) toggl = TogglHelper("url", None) toggl.get = Mock() toggl.get.return_value = [ TogglEntry(None, 3600, "2016-03-02T01:01:01", 777, "test SLUG-333", self.jira_config) ] jira.get = Mock() jira.get.return_value = [ JiraTimeEntry( 777, "2016-01-01T01:02:03", "john doe", 3600, "2016-03-02T01:01:01", "SLUG-333", "test SLUG-333 [toggl#777]", ) ] jira.update = MagicMock() s = Synchronizer(Mock(), jira, toggl, None, raise_errors=True) s.start(1) toggl.get.assert_called_once_with(1) jira.get.assert_called_once_with('SLUG-333') jira.update.assert_not_called()
def test_sync_single_toggl_already_inserted_in_jira(self): jira = JiraHelper(None, None, None, False) jira.get = Mock() jira.put = Mock() jira.update = Mock() toggl = TogglHelper("url", None) toggl.get = Mock() toggl.get.return_value = [ TogglEntry( None, 3600, "2016-01-01T01:01:01", 17, "SLUG-987 hard work", self.jira_config, ) ] jira.get.return_value = [ JiraTimeEntry( 222, "2016-05-01T04:02:22", "john doe", 3600, "2016-01-01T01:01:01", "SLUG-987", "SLUG-987 hard work [toggl#17]", ) ] s = Synchronizer(MagicMock(), jira, toggl, None, raise_errors=True) s.start(1) jira.update.assert_not_called() jira.put.assert_not_called()
def test_sync_single_toggl_modified_entry(self): jira = JiraHelper(None, None, None, False) jira.get = Mock() jira.update = Mock() toggl = TogglHelper("url", None) toggl.get = Mock() toggl.get.return_value = [ TogglEntry( None, 2 * 3600, "2016-01-01T01:01:01", 17, "SLUG-987 hard work", self.jira_config, ) ] jira.get.return_value = [ JiraTimeEntry( 222, "2016-05-01T04:02:22", "john doe", 1, "2016-01-01T01:01:01", "SLUG-987", "SLUG-987 hard work [toggl#17]", ) ] s = Synchronizer(MagicMock(), jira, toggl, None, raise_errors=True) s.start(1) jira.update.assert_called_once_with( id=222, issueId="SLUG-987", started="2016-01-01T01:01:01", seconds=2 * 3600, comment="SLUG-987 hard work [toggl#17]", )