Example #1
0
    def test_saves_to_file(self):
        state = SyncState(self.state_path)
        state.push_path("a")
        state.push_path("b")
        state.sync_path("c")
        state.sync_path("d")

        self.assertStateFile("""\
2016-01-01T12:00:00 +push a
2016-01-01T12:00:00 +push b
2016-01-01T12:00:00 +sync c
2016-01-01T12:00:00 +sync d
""")

        state.push_done("a")
        state.sync_done("d")

        self.assertStateFile("""\
2016-01-01T12:00:00 +push a
2016-01-01T12:00:00 +push b
2016-01-01T12:00:00 +sync c
2016-01-01T12:00:00 +sync d
2016-01-01T12:00:00 -push a
2016-01-01T12:00:00 -sync d
""")
Example #2
0
    def test_saves_to_file(self):
        state = SyncState(self.state_path)
        state.push_path("a")
        state.push_path("b")
        state.sync_path("c")
        state.sync_path("d")

        self.assertStateFile("""\
2016-01-01T12:00:00 +push a
2016-01-01T12:00:00 +push b
2016-01-01T12:00:00 +sync c
2016-01-01T12:00:00 +sync d
""")

        state.push_done("a")
        state.sync_done("d")

        self.assertStateFile("""\
2016-01-01T12:00:00 +push a
2016-01-01T12:00:00 +push b
2016-01-01T12:00:00 +sync c
2016-01-01T12:00:00 +sync d
2016-01-01T12:00:00 -push a
2016-01-01T12:00:00 -sync d
""")
Example #3
0
    def test_records_state_in_memory(self):
        state = SyncState(self.state_path)
        state.push_path("a")
        state.push_path("b")
        state.sync_path("c")
        state.sync_path("d")
        self.assertEqual(state.current_state, {
            "push": ["a", "b"],
            "sync": ["c", "d"],
        })

        state.push_done("a")
        state.sync_done("d")

        self.assertEqual(state.current_state, {
            "push": ["b"],
            "sync": ["c"],
        })
Example #4
0
    def test_records_state_in_memory(self):
        state = SyncState(self.state_path)
        state.push_path("a")
        state.push_path("b")
        state.sync_path("c")
        state.sync_path("d")
        self.assertEqual(state.current_state, {
            "push": set(("a", "b")),
            "sync": set(("c", "d"))
        })

        state.push_done("a")
        state.sync_done("d")

        self.assertEqual(state.current_state, {
            "push": set(("b",)),
            "sync": set(("c",))
        })