def test_visited_case_sensitivity(self): """ Checks that the store is not case sensitve """ v = visited.Visited() v.set_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000) self.assertTrue( v.is_visited({ 'system': 'SOL', 'body': 'EARTH', 'lat': 0, 'lon': 0 }, when=1000)) self.assertFalse( v.is_visited({ 'system': 'SOL', 'body': 'EARTH', 'lat': 0, 'lon': 0 }, when=1000 + 7 * 24 * 3600))
def test_visited_recently(self): """ Checks that the visited state is remembered and expires after time """ v = visited.Visited() v.set_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000) self.assertTrue( v.is_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000)) self.assertFalse( v.is_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000 + 7 * 24 * 3600))
def test_never_visited(self): v = visited.Visited() self.assertFalse( v.is_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000))
def plugin_start(): watcher.MatsLoaderRemote(local_file("mats-cache.json"), this.status_queue).start() this.visited = visited.Visited(config.get("matgrindr.visited")) this.mats = mats.Materials(None, this.visited) selected = config.get("matgrindr.selected") or [] this.events = events.EventEngine(this.mats, selected, this.visited) this._IMG_CLIPBOARD = tk.PhotoImage(file=local_file('clipboard-2x.gif')) this._IMG_SKIP = tk.PhotoImage(file=local_file('circle-x-2x.gif')) return "Matgrindr"
def test_visited_multiple_times(self): v = visited.Visited() v.set_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000) self.assertTrue( v.is_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000)) self.assertFalse( v.is_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000 + 7 * 24 * 3600)) v.set_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=3000) # Now should be using the new recorded visit at 3000 secs self.assertTrue( v.is_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000 + 7 * 24 * 3600)) self.assertFalse( v.is_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=3000 + 7 * 24 * 3600))
def test_save(self): v = visited.Visited() v.set_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000) self.assertTrue( v.is_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000)) self.assertNotEqual('[]', v.save(when=1000)) self.assertEqual('[]', v.save(when=1000 + 7 * 24 * 3600))
def test_is_dirty(self): v = visited.Visited() self.assertFalse(v.is_dirty()) v.set_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000) self.assertTrue(v.is_dirty()) v.save() self.assertFalse(v.is_dirty()) v.set_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1001) self.assertTrue(v.is_dirty())
def test_visited_recently_with_no_respawn(self): """ Checks that the visited state is remembered and we understand zero periods """ v = visited.Visited() v.set_visited( { 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0, 'respawn_days': 0 }, when=1000) self.assertFalse( v.is_visited({ 'system': 'Sol', 'body': 'Earth', 'lat': 0, 'lon': 0 }, when=1000))