コード例 #1
0
    def test_synchronize(self):
        existing_rows = [
            fixtures.row(id=1),
            fixtures.row(id=2),
            fixtures.row(id=3)
        ]
        self.db_client.read.return_value = existing_rows

        self.asana_client.tasks.find_by_project.return_value = [
            fixtures.task(id=2),
            fixtures.task(id=3),
            fixtures.task(id=4)
        ]

        project = Project(self.asana_client, self.db_client, self.workspace,
                          self.config, [SimpleField("id", SqlType.INTEGER)])
        project.synchronize()

        self.asana_client.tasks.find_by_project.assert_called_with(1234,
                                                                   fields="id")
        self.db_client.read.assert_called_with('SELECT id FROM "test_table";')
        self.db_client.write.assert_called_with(
            'DELETE FROM "test_table" WHERE id = ?;', 1)
        self.db_client.write.assert_has_calls([
            mock.call('INSERT OR REPLACE INTO "test_table" (id) VALUES (?);',
                      2),
            mock.call('INSERT OR REPLACE INTO "test_table" (id) VALUES (?);',
                      3),
            mock.call('INSERT OR REPLACE INTO "test_table" (id) VALUES (?);',
                      4)
        ])
コード例 #2
0
    def test_export(self):
        self.asana_client.tasks.find_by_project.return_value = [
            fixtures.task(id=1),
            fixtures.task(id=2),
            fixtures.task(id=3)
        ]

        project = Project(self.asana_client, self.db_client, self.workspace,
                          self.config, [SimpleField("id", SqlType.INTEGER)])
        project.export()

        self.asana_client.tasks.find_by_project.assert_called_with(1234,
                                                                   fields="id")
        self.db_client.read.assert_not_called()
        self.db_client.write.assert_has_calls([
            mock.call('INSERT OR REPLACE INTO "test_table" (id) VALUES (?);',
                      1),
            mock.call('INSERT OR REPLACE INTO "test_table" (id) VALUES (?);',
                      2),
            mock.call('INSERT OR REPLACE INTO "test_table" (id) VALUES (?);',
                      3)
        ])
コード例 #3
0
 def test_field_definition(self):
     simple_field = SimpleField("test", SqlType.INTEGER)
     self.assertEquals(simple_field.field_definition_sql(),
                       '"test" INTEGER')
コード例 #4
0
 def test_get_data_from_task(self):
     task = {"test": 123}
     simple_field = SimpleField("test", SqlType.INTEGER)
     self.assertEquals(simple_field.get_data_from_task(task), 123)
コード例 #5
0
 def test_required_fields(self):
     simple_field = SimpleField("test", SqlType.INTEGER)
     self.assertSetEqual(simple_field.required_fields(), set(["test"]))
コード例 #6
0
def NameField():
    return SimpleField("name", SqlType.STRING)
コード例 #7
0
def AssigneeStatus():
    return SimpleField("assignee_status", SqlType.STRING)
コード例 #8
0
def NumHearts():
    return SimpleField("num_hearts", SqlType.INTEGER, default=0)
コード例 #9
0
def DueOnField():
    return SimpleField("due_on", SqlType.DATE)
コード例 #10
0
def TaskIdPrimaryKeyField():
    return SimpleField("id", SqlType.INTEGER, primary_key=True)
コード例 #11
0
def CompletedAtField():
    return SimpleField("completed_at", SqlType.DATETIME)
コード例 #12
0
def CompletedField():
    return SimpleField("completed", SqlType.BOOLEAN, default=False)
コード例 #13
0
def ModifiedAtField():
    return SimpleField("modified_at", SqlType.DATETIME)
コード例 #14
0
def CreatedAtField():
    return SimpleField("created_at", SqlType.DATETIME)
コード例 #15
0
def NotesField():
    return SimpleField("notes", SqlType.TEXT)
コード例 #16
0
 def test_primary_key(self):
     simple_field = SimpleField("test", SqlType.INTEGER, primary_key=True)
     self.assertEquals(simple_field.field_definition_sql(),
                       '"test" INTEGER NOT NULL PRIMARY KEY')
コード例 #17
0
 def test_default_value(self):
     task = {}
     simple_field = SimpleField("test", SqlType.INTEGER, default=123)
     self.assertEquals(simple_field.get_data_from_task(task), 123)
コード例 #18
0
def DueAtField():
    return SimpleField("due_at", SqlType.DATETIME)