tradedangerous 10.13.10__tar.gz → 10.14.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tradedangerous might be problematic. Click here for more details.

Files changed (97) hide show
  1. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/PKG-INFO +4 -1
  2. tradedangerous-10.14.2/pyproject.toml +9 -0
  3. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/setup.py +1 -1
  4. tradedangerous-10.14.2/tests/test_bootstrap_commands.py +53 -0
  5. tradedangerous-10.14.2/tests/test_bootstrap_plugins.py +27 -0
  6. tradedangerous-10.14.2/tests/test_cache.py +39 -0
  7. tradedangerous-10.14.2/tests/test_commands.py +42 -0
  8. tradedangerous-10.14.2/tests/test_fs.py +44 -0
  9. tradedangerous-10.14.2/tests/test_peek.py +110 -0
  10. tradedangerous-10.14.2/tests/test_tools.py +13 -0
  11. tradedangerous-10.14.2/tests/test_trade.py +84 -0
  12. tradedangerous-10.14.2/tests/test_trade_import_eddblink.py +58 -0
  13. tradedangerous-10.14.2/tests/test_trade_run.py +64 -0
  14. tradedangerous-10.14.2/tests/test_utils.py +27 -0
  15. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/cache.py +2 -2
  16. tradedangerous-10.14.2/tradedangerous/plugins/spansh_plug.py +379 -0
  17. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/version.py +1 -1
  18. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous.egg-info/PKG-INFO +4 -1
  19. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous.egg-info/SOURCES.txt +13 -0
  20. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous.egg-info/requires.txt +1 -0
  21. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/LICENSE +0 -0
  22. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/README.md +0 -0
  23. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/setup.cfg +0 -0
  24. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/__init__.py +0 -0
  25. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/cli.py +0 -0
  26. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/TEMPLATE.py +0 -0
  27. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/__init__.py +0 -0
  28. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/buildcache_cmd.py +0 -0
  29. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/buy_cmd.py +0 -0
  30. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/commandenv.py +0 -0
  31. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/exceptions.py +0 -0
  32. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/export_cmd.py +0 -0
  33. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/import_cmd.py +0 -0
  34. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/local_cmd.py +0 -0
  35. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/market_cmd.py +0 -0
  36. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/nav_cmd.py +0 -0
  37. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/olddata_cmd.py +0 -0
  38. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/parsing.py +0 -0
  39. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/rares_cmd.py +0 -0
  40. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/run_cmd.py +0 -0
  41. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/sell_cmd.py +0 -0
  42. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/shipvendor_cmd.py +0 -0
  43. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/station_cmd.py +0 -0
  44. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/trade_cmd.py +0 -0
  45. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/update_cmd.py +0 -0
  46. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/commands/update_gui.py +0 -0
  47. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/corrections.py +0 -0
  48. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/csvexport.py +0 -0
  49. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/edscupdate.py +0 -0
  50. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/edsmupdate.py +0 -0
  51. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/formatting.py +0 -0
  52. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/fs.py +0 -0
  53. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/gui.py +0 -0
  54. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/jsonprices.py +0 -0
  55. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/mapping.py +0 -0
  56. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/mfd/__init__.py +0 -0
  57. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/mfd/saitek/__init__.py +0 -0
  58. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/mfd/saitek/directoutput.py +0 -0
  59. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/mfd/saitek/x52pro.py +0 -0
  60. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/checkpricebounds.py +0 -0
  61. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/clipboard.py +0 -0
  62. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/coord64.py +0 -0
  63. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/derp-sentinel.py +0 -0
  64. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/diff-system-csvs.py +0 -0
  65. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/eddb.py +0 -0
  66. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/eddn.py +0 -0
  67. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/edsc.py +0 -0
  68. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/edsm.py +0 -0
  69. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/importeddbstats.py +0 -0
  70. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/prices-json-exp.py +0 -0
  71. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/misc/progress.py +0 -0
  72. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/plugins/__init__.py +0 -0
  73. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/plugins/edapi_plug.py +0 -0
  74. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/plugins/edcd_plug.py +0 -0
  75. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/plugins/eddblink_plug.py +0 -0
  76. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/plugins/edmc_batch_plug.py +0 -0
  77. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/plugins/journal_plug.py +0 -0
  78. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/plugins/netlog_plug.py +0 -0
  79. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/prices.py +0 -0
  80. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/submit-distances.py +0 -0
  81. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/templates/Added.csv +0 -0
  82. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/templates/DefaultShipIndex.json +0 -0
  83. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/templates/RareItem.csv +0 -0
  84. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/templates/TradeDangerous.sql +0 -0
  85. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/tools.py +0 -0
  86. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/trade.py +0 -0
  87. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/tradecalc.py +0 -0
  88. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/tradedb.py +0 -0
  89. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/tradeenv.py +0 -0
  90. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/tradeexcept.py +0 -0
  91. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/tradegui.py +0 -0
  92. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/transfers.py +0 -0
  93. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous/utils.py +0 -0
  94. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous.egg-info/dependency_links.txt +0 -0
  95. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous.egg-info/entry_points.txt +0 -0
  96. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous.egg-info/not-zip-safe +0 -0
  97. {tradedangerous-10.13.10 → tradedangerous-10.14.2}/tradedangerous.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tradedangerous
3
- Version: 10.13.10
3
+ Version: 10.14.2
4
4
  Summary: Trade-Dangerous is a set of powerful trading tools for Elite Dangerous, organized around one of the most powerful trade run optimizers available.
5
5
  Home-page: https://github.com/eyeonus/Trade-Dangerous
6
6
  Author: eyeonus
@@ -19,6 +19,9 @@ Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
19
19
  Classifier: Operating System :: OS Independent
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
+ Requires-Dist: requests
23
+ Requires-Dist: appJar
24
+ Requires-Dist: pysimdjson
22
25
 
23
26
 
24
27
  ----------
@@ -0,0 +1,9 @@
1
+ [tool.semantic_release.branches.main]
2
+ match = "(main|master|release/v1)"
3
+ prerelease_token = "rc"
4
+ prerelease = false
5
+
6
+ [tool.semantic_release]
7
+ version_variables = [
8
+ "tradedangerous/version.py:__version__",
9
+ ]
@@ -27,7 +27,7 @@ exec(open("tradedangerous/version.py").read()) # pylint: disable=W0122
27
27
 
28
28
  setup(name = package,
29
29
  version = __version__, # pylint: disable=E0602
30
- install_requires = ["requests", "appJar"],
30
+ install_requires = ["requests", "appJar", "pysimdjson"],
31
31
  setup_requires = ["pytest-runner"],
32
32
  tests_require = ["pytest"],
33
33
  packages = ['tradedangerous', 'tradedangerous.commands', 'tradedangerous.mfd', 'tradedangerous.mfd.saitek', 'tradedangerous.misc', 'tradedangerous.plugins'],
@@ -0,0 +1,53 @@
1
+ import unittest
2
+
3
+
4
+ class TestBootstrapCommands(unittest.TestCase):
5
+ def test_import_commands(self):
6
+ from tradedangerous import commands
7
+
8
+ self.assertIn('buildcache', commands.commandIndex)
9
+ self.assertIn('buy', commands.commandIndex)
10
+
11
+
12
+ def test_import_buildcache_cmd(self):
13
+ from tradedangerous.commands import buildcache_cmd
14
+
15
+ def test_import_buy(self):
16
+ from tradedangerous.commands import buy_cmd
17
+
18
+ def test_import_import_cmd(self):
19
+ from tradedangerous.commands import import_cmd
20
+
21
+ def test_import_local_cmd(self):
22
+ from tradedangerous.commands import local_cmd
23
+
24
+ def test_import_market_cmd(self):
25
+ from tradedangerous.commands import market_cmd
26
+
27
+ def test_import_nav_cmd(self):
28
+ from tradedangerous.commands import nav_cmd
29
+
30
+ def test_import_olddata_cmd(self):
31
+ from tradedangerous.commands import olddata_cmd
32
+
33
+ def test_import_rares_cmd(self):
34
+ from tradedangerous.commands import rares_cmd
35
+
36
+ def test_import_run_cmd(self):
37
+ from tradedangerous.commands import run_cmd
38
+
39
+ def test_import_sell_cmd(self):
40
+ from tradedangerous.commands import sell_cmd
41
+
42
+ def test_import_shipvendor_cmd(self):
43
+ from tradedangerous.commands import shipvendor_cmd
44
+
45
+ def test_import_station_cmd(self):
46
+ from tradedangerous.commands import station_cmd
47
+
48
+ def test_import_update_cmd(self):
49
+ from tradedangerous.commands import update_cmd
50
+
51
+ def test_import_update_gui(self):
52
+ from tradedangerous.commands import update_gui
53
+
@@ -0,0 +1,27 @@
1
+ import pytest
2
+
3
+ class TestBootstrapPlugins(object):
4
+ def test_import_traded(self):
5
+ import tradedangerous as td
6
+
7
+ def test_import_plugins(self):
8
+ from tradedangerous import plugins
9
+
10
+ def test_import_plugins_eddblink(self):
11
+ from tradedangerous.plugins import eddblink_plug
12
+
13
+ @pytest.mark.skip("edapi requires secrets and stuff")
14
+ def test_import_plugins_edapi(self):
15
+ from tradedangerous.plugins import edapi_plug
16
+
17
+ def test_import_plugins_edcd(self):
18
+ from tradedangerous.plugins import edcd_plug
19
+
20
+ def test_import_plugins_edmc_batch(self):
21
+ from tradedangerous.plugins import edmc_batch_plug
22
+
23
+ def test_import_plugins_journal(self):
24
+ from tradedangerous.plugins import journal_plug
25
+
26
+ def test_import_plugins_netlog(self):
27
+ from tradedangerous.plugins import netlog_plug
@@ -0,0 +1,39 @@
1
+ import pytest
2
+ from collections import namedtuple
3
+
4
+ from tradedangerous import cache
5
+
6
+ FakeFile = namedtuple('FakeFile', ['name'])
7
+
8
+ class TestCache(object):
9
+ def test_parseSupply(self):
10
+ fil = FakeFile('faked-file.prices')
11
+ reading = '897H'
12
+ demandUnits, demandLevel = cache.parseSupply(
13
+ fil,
14
+ 10,
15
+ 'demand',
16
+ reading)
17
+
18
+ assert demandUnits == 897
19
+ assert demandLevel == 3
20
+
21
+ def test_parseSupply_bad_level(self):
22
+ fil = FakeFile('faked-file.prices')
23
+ reading = '897X'
24
+ with pytest.raises(cache.SupplyError, match='Unrecognized level suffix'):
25
+ cache.parseSupply(
26
+ fil,
27
+ 10,
28
+ 'demand',
29
+ reading)
30
+
31
+ def test_parseSupply_bad_units(self):
32
+ fil = FakeFile('faked-file.prices')
33
+ reading = '-10H'
34
+ with pytest.raises(cache.SupplyError, match='Unrecognized units/level value'):
35
+ cache.parseSupply(
36
+ fil,
37
+ 10,
38
+ 'demand',
39
+ reading)
@@ -0,0 +1,42 @@
1
+ #! /usr/bin/env python
2
+ # pytest
3
+
4
+ from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
5
+ import sys
6
+ import pytest
7
+ from tradedangerous import commands
8
+ from tradedangerous.commands.exceptions import UsageError, CommandLineError
9
+
10
+ @pytest.fixture
11
+ def cmd():
12
+ return commands.CommandIndex()
13
+
14
+ prog = "trade.py"
15
+
16
+ class TestCommands(object):
17
+
18
+ def test_dashh(self, cmd):
19
+ with pytest.raises(UsageError):
20
+ cmd.parse([prog, '-h'])
21
+
22
+ def test_local_dashh(self, cmd):
23
+ with pytest.raises(UsageError):
24
+ cmd.parse([prog, 'local', '-h'])
25
+
26
+ def test_invalid_cmd(self, cmd):
27
+ with pytest.raises(CommandLineError):
28
+ cmd.parse([prog, 'fnarg'])
29
+
30
+ def test_local_no_args(self, cmd):
31
+ with pytest.raises(CommandLineError):
32
+ cmd.parse([prog, 'local'])
33
+
34
+ def test_local_dashv(self, cmd):
35
+ with pytest.raises(CommandLineError):
36
+ cmd.parse([prog, 'local', '-v'])
37
+
38
+ def test_local_validsys(self, cmd):
39
+ cmd.parse([prog, 'local', 'ibootis'])
40
+
41
+ def test_local_validsys_dashv(self, cmd):
42
+ cmd.parse([prog, 'local', 'ibootis', '-v'])
@@ -0,0 +1,44 @@
1
+
2
+ from shutil import rmtree
3
+ from pathlib import Path
4
+ import pytest
5
+
6
+ from tradedangerous import fs, TradeEnv
7
+
8
+ def setup_module():
9
+ tdenv = TradeEnv()
10
+ p = Path(tdenv.tmpDir)
11
+ if p.exists() and p.is_dir():
12
+ rmtree(tdenv.tmpDir)
13
+ fs.ensurefolder(tdenv.tmpDir)
14
+
15
+ @pytest.fixture
16
+ def tdenv():
17
+ return TradeEnv()
18
+
19
+
20
+ class TestFS(object):
21
+
22
+ def test_copy(self, tdenv):
23
+ src = fs.pathify(tdenv.templateDir, 'TradeDangerous.sql')
24
+ dst = fs.pathify(tdenv.tmpDir, src.name)
25
+ fs.copy(src, dst)
26
+ assert dst.exists() and dst.is_file()
27
+
28
+ def test_ensureflag(self, tdenv):
29
+ self.result = False
30
+ flagfile = fs.pathify(tdenv.tmpDir, 'flagtest')
31
+ if flagfile.exists():
32
+ flagfile.unlink()
33
+
34
+ def action():
35
+ self.result = True
36
+
37
+ flag = fs.ensureflag(flagfile, action)
38
+ assert self.result == True
39
+
40
+ def test_copyallfiles(self, tdenv):
41
+ setup_module()
42
+ fs.copyallfiles(tdenv.templateDir, tdenv.tmpDir)
43
+ test = Path(tdenv.tmpDir, 'Added.csv')
44
+ assert test.exists() and test.is_file()
@@ -0,0 +1,110 @@
1
+ import os
2
+ import random
3
+
4
+ import pytest
5
+
6
+ from tradedangerous.tradedb import Trade, TradeDB, Station, System
7
+ from .helpers import copy_fixtures
8
+
9
+ ORIGIN='Shinrarta Dezhra'
10
+ #tdb = None
11
+
12
+ def setup_module():
13
+ copy_fixtures()
14
+
15
+ def route_to_closest(tdb:TradeDB, origin, destinations, maxLy=15):
16
+ closest = min(destinations, key=lambda candidate: candidate.distanceTo(origin))
17
+ print("Closest:", closest.name(), closest.distanceTo(origin))
18
+ route = tdb.getRoute(origin, closest, maxLy)
19
+ if not route:
20
+ print("No route found.")
21
+ else:
22
+ print("Route:", ", ".join(system.name() for system, distance in route))
23
+ return route
24
+
25
+ def should_skip() -> bool:
26
+ return False # os.getenv("CI") != None
27
+
28
+
29
+ class TestPeek(object):
30
+ """
31
+ Tests based on https://github.com/eyeonus/Trade-Dangerous/wiki/Python-Quick-Peek
32
+ """
33
+
34
+ @pytest.mark.skipif(should_skip(), reason="does not work with CI")
35
+ def test_quick_origin(self, tdb:TradeDB):
36
+ # Look up a particular system
37
+ origin = tdb.lookupSystem(ORIGIN)
38
+
39
+ assert 55.71875 == origin.posX
40
+ assert 17.59375 == origin.posY
41
+ assert 27.15625, origin.posZ
42
+
43
+ stations = origin.stations
44
+ assert len(stations) == 5
45
+ for station in stations:
46
+ assert isinstance(station, Station)
47
+
48
+ # Look up a station
49
+ abe1 = tdb.lookupStation("Abraham Lincoln")
50
+ assert isinstance(abe1, Station)
51
+
52
+
53
+ # Look up a station in a particular system
54
+ sol = tdb.lookupSystem("sol")
55
+ abe2 = tdb.lookupStation("Abraham Lincoln", sol)
56
+
57
+ assert abe1 == abe2
58
+
59
+ @pytest.mark.skipif(should_skip(), reason="does not work with CI")
60
+ def test_quick_lookupPlace(self, tdb):
61
+ # Look up a system or station using the flexible naming mechanism
62
+ phoenix = tdb.lookupPlace("dunyach")
63
+ assert str(type(phoenix)) == "<class 'tradedangerous.tradedb.Station'>" # tell me what type of thing "phoenix" is...
64
+
65
+ sol = tdb.lookupPlace("@sol")
66
+ assert str(type(sol)) == "<class 'tradedangerous.tradedb.System'>"
67
+
68
+ lave = tdb.lookupPlace("stein")
69
+ assert isinstance(lave, System)
70
+
71
+ abe = tdb.lookupPlace("sol/hamlinc")
72
+ assert isinstance(abe, Station)
73
+
74
+ @pytest.mark.skipif(should_skip(), reason="does not work with CI")
75
+ def test_quick_five(self, tdb):
76
+ systemTable = tdb.systemByID.values()
77
+ visitMe = random.sample(list(systemTable), 5)
78
+ origin = tdb.lookupPlace(ORIGIN)
79
+ # Call distanceTo(origin) on every member of visitMe and
80
+ # then retrieve the one with the lowest distance.
81
+ closest = min(visitMe, key=lambda candidate: candidate.distanceTo(origin))
82
+ print("{start} -> {dest}: {dist:.2f} ly".format(
83
+ start=origin.name(), dest=closest.name(),
84
+ dist=origin.distanceTo(closest),
85
+ ))
86
+ route = tdb.getRoute(origin, closest, 15)
87
+ if not route:
88
+ print("Shame, couldn't find a route.")
89
+ else:
90
+ # Route is a list of Systems. Turn it into a list of
91
+ # System names...
92
+ routeNames = [ system.name() for system, distance in route ]
93
+ print("Route:", routeNames)
94
+
95
+ route_to_closest(tdb, origin, visitMe)
96
+ route_to_closest(tdb, origin, visitMe, 20)
97
+
98
+ # lets change origin
99
+ origin = tdb.lookupSystem("Toolfa")
100
+ route_to_closest(tdb, origin, visitMe)
101
+
102
+ @pytest.mark.skipif(should_skip(), reason="does not work with CI")
103
+ def test_three_different(self, tdb):
104
+ # lets try a different route:
105
+ sol = tdb.lookupSystem("sol")
106
+ lhs = tdb.lookupSystem("lhs 380")
107
+ bhr = tdb.lookupSystem("bhritzameno")
108
+
109
+ result = route_to_closest(tdb, sol, [ lhs, bhr ])
110
+
@@ -0,0 +1,13 @@
1
+ import pytest
2
+
3
+ from tradedangerous import tools
4
+ from .helpers import copy_fixtures
5
+
6
+
7
+ def setup_module():
8
+ copy_fixtures()
9
+
10
+
11
+ class TestTools(object):
12
+ def test_derp(self, capsys):
13
+ tools.test_derp()
@@ -0,0 +1,84 @@
1
+ import pytest
2
+
3
+ from tradedangerous.cli import trade
4
+ from tradedangerous.commands.exceptions import UsageError
5
+ from .helpers import copy_fixtures, regex_findin, remove_fixtures
6
+
7
+ PROG = "trade"
8
+
9
+
10
+ def setup_module():
11
+ copy_fixtures()
12
+
13
+
14
+ def teardown_module():
15
+ remove_fixtures()
16
+
17
+
18
+ class TestTrade(object):
19
+ def test_local_help(self):
20
+ with pytest.raises(UsageError):
21
+ trade([PROG, "local", "-h"])
22
+
23
+ def test_local_sol(self, capsys):
24
+ trade([PROG, "local", "--ly=10", "--detail", "sol"])
25
+ captured = capsys.readouterr()
26
+ assert "Sol 0" in captured.out
27
+ assert "Ehrlich City" in captured.out
28
+
29
+ def test_sell(self, capsys):
30
+ trade([PROG, "sell", "--near=sol", "hydrogen fuel"])
31
+ captured = capsys.readouterr()
32
+ assert "Sol/Mars High" in captured.out
33
+
34
+ def test_buy(self, capsys):
35
+ trade([PROG, "buy", "--near=sol", "hydrogen fuel"])
36
+ captured = capsys.readouterr()
37
+ assert "Cost Units DistLy Age/days" in captured.out
38
+
39
+ def test_export_station(self, capsys):
40
+ trade([PROG, "export", "-T", "System"])
41
+ captured = capsys.readouterr()
42
+ assert "NOTE: Export Table 'System'" in captured.out
43
+ # TODO: check that System.csv has a fresh date
44
+
45
+ def test_station_remove(self, capsys):
46
+ # "Dekker's Yard"
47
+ trade([PROG, "station", "-rm", "sol/dekkers"])
48
+ captured = capsys.readouterr()
49
+ assert regex_findin(r"NOTE: Sol/Dekker's Yard \(#\d+\) removed", captured.out)
50
+
51
+ def test_station_add(self, capsys):
52
+ # "Dekker's Yard"
53
+ trade([
54
+ PROG, "station", "--add", "--ls-from-star=5",
55
+ "--market=Y",
56
+ "--black-market=?",
57
+ "--outfitting=?",
58
+ "--pad-size=s",
59
+ "--rearm=?",
60
+ "--refuel=Y",
61
+ "--repair=?",
62
+ "--no-export",
63
+ "sol/Dangerous Delight"])
64
+ captured = capsys.readouterr()
65
+ assert regex_findin(r"NOTE: Sol/Dangerous Delight \(#\d+\) added", captured.out)
66
+
67
+ def test_nav(self, capsys):
68
+ trade([PROG, "nav", "--ly-per=50", "sol", "Shinrarta Dezhra"])
69
+ captured = capsys.readouterr()
70
+ assert "System JumpLy" in captured.out
71
+ assert "Shinrarta Dezhra 47" in captured.out
72
+
73
+ def test_market(self, capsys):
74
+ trade([PROG, "market", "sol/abr"])
75
+ captured = capsys.readouterr()
76
+ assert regex_findin("Item[ ]{3,}Buying Selling[ ]{2,}Supply", captured.out)
77
+ assert "Hydrogen Fuel" in captured.out
78
+ assert regex_findin("Water[ ]{3,}323", captured.out)
79
+
80
+ @pytest.mark.slow
81
+ def test_import_edcd(self, capsys):
82
+ trade([PROG, "import", "-P=edcd", "--opt=commodity"])
83
+ captured = capsys.readouterr()
84
+ assert regex_findin(r"NOTE: Found \d+ item\(s\)", captured.out)
@@ -0,0 +1,58 @@
1
+ import os
2
+
3
+ import pytest
4
+
5
+ from tradedangerous.cli import trade
6
+ from tradedangerous.plugins import eddblink_plug as module
7
+ from .helpers import copy_fixtures, tdfactory
8
+
9
+ PROG = "trade"
10
+
11
+
12
+ @pytest.fixture
13
+ def td():
14
+ copy_fixtures()
15
+ tdb, tdenv = tdfactory()
16
+ yield tdb, tdenv
17
+ # this will happen when the fixture goes out of use
18
+ tdb.close()
19
+
20
+
21
+ class TestTradeImportEddblink(object):
22
+ def test_create_instance(self, monkeypatch, td):
23
+ tdb, tdenv = td
24
+ plug = module.ImportPlugin(tdb, tdenv)
25
+ assert module.UPGRADES == "modules.json"
26
+ assert os.path.join('data', 'eddb') in str(plug.dataPath)
27
+
28
+ monkeypatch.setitem(os.environ, 'TD_EDDB', '/my/testdir')
29
+ plug = module.ImportPlugin(tdb, tdenv)
30
+ assert os.path.join('my', 'testdir') in str(plug.dataPath)
31
+
32
+ def test_upgrades(self, capsys, td):
33
+ tdb, tdenv = td
34
+ plug = module.ImportPlugin(tdb, tdenv)
35
+ assert module.UPGRADES == "modules.json"
36
+ assert os.path.join('data', 'eddb') in str(plug.dataPath)
37
+ plug.downloadFile(module.UPGRADES, plug.upgradesPath)
38
+ assert (plug.dataPath / plug.upgradesPath).is_file()
39
+
40
+ @pytest.mark.superslow
41
+ def test_import_clean(self, capsys):
42
+ trade([PROG, "import", "-P=eddblink", '--opt=clean,skipvend,force'])
43
+ captured = capsys.readouterr()
44
+ # with capsys.disabled():
45
+ # print("Here")
46
+ # print(captured.out)
47
+ # print("to Here")
48
+ assert "NOTE: Import completed." in captured.out
49
+
50
+ @pytest.mark.superslow
51
+ def test_import_upgrade(self, capsys):
52
+ trade([PROG, "import", "-P=eddblink", '--opt=upgrade'])
53
+ captured = capsys.readouterr()
54
+ with capsys.disabled():
55
+ print("Here")
56
+ print(captured.out)
57
+ print("to Here")
58
+ assert "NOTE: Import completed." in captured.out
@@ -0,0 +1,64 @@
1
+ import io
2
+
3
+ import pytest
4
+
5
+ from tradedangerous.cli import trade
6
+
7
+ from .helpers import copy_fixtures, regex_findin, replace_stdin
8
+
9
+ PROG = "trade"
10
+
11
+
12
+ def setup_module():
13
+ copy_fixtures()
14
+
15
+
16
+ class TestTradeRun(object):
17
+ def test_run1(self, capsys):
18
+ trade([PROG, "run", "--capacity=10", "--credits=10000", "--from=sol/abr", "--jumps-per=3", "--ly-per=10.5", "--no-planet"])
19
+ captured = capsys.readouterr()
20
+ assert "Sol/Abraham Lincoln: 10 x Hydrogen Fuel," in captured.out
21
+ assert "Sol/Burnell Station: 2 x Silver," in captured.out
22
+ assert "560cr (213/ton)" in captured.out
23
+
24
+ @pytest.mark.slow
25
+ def test_run2(self, capsys):
26
+ trade([
27
+ PROG, "run", "-vv", "--progress", "--empty=82",
28
+ "--cap=212", "--jumps=4", "--cr=2153796", "--from=sol/abr",
29
+ "--hops=6", "--ls-m=8000", "--sup=10000",
30
+ "--pad=L", "--ly=25", "--prune-hop=3", "--prune-sc=40"])
31
+ captured = capsys.readouterr()
32
+ assert regex_findin(r"=> est [\d\s,]+cr total", captured.out)
33
+
34
+ @pytest.mark.slow
35
+ def test_run3(self, capsys):
36
+ """Testing --checklist
37
+ """
38
+ # monkeypatch.setattr('sys.stdin', io.StringIO('100'))
39
+ STEPS = 37
40
+ with replace_stdin(io.StringIO('\n' * STEPS)):
41
+ trade([
42
+ PROG, "run", "-vv", "--progress", "--empty=82", "--checklist",
43
+ "--cap=212", "--jumps=4", "--cr=2153796", "--from=sol/abr",
44
+ "--hops=6", "--ls-m=8000", "--sup=10000",
45
+ "--pad=L", "--ly=25", "--prune-hop=3", "--prune-sc=40"])
46
+ captured = capsys.readouterr()
47
+ # with capsys.disabled():
48
+ # print("Here")
49
+ # print(captured.out)
50
+ # print("to Here")
51
+ assert "BEGINNING CHECKLIST FOR Sol/Abraham Lincoln -> LHS 449/Fisher Point" in captured.out
52
+ assert "35 : Sell 212 x Polymers"
53
+
54
+ def test_run4(self, capsys):
55
+ trade([PROG, "run", "--capacity=10", "--credits=10000", "--from=sol/abr", "--jumps-per=3", "--ly-per=10.5", "--start-jumps=2"])
56
+ captured = capsys.readouterr()
57
+ # with capsys.disabled():
58
+ # print("Here")
59
+ # print(captured.out)
60
+ # print("to Here")
61
+ assert "Sol/Haberlandt Survey -> Sol/Durrance Camp" in captured.out
62
+ assert " Sol/Haberlandt Survey: 5 x Reactive Armour," in captured.out
63
+ assert " Sol/Ehrlich City: 10 x Building Fabricators," in captured.out
64
+ assert " Sol/Durrance Camp +10 925cr (728/ton)"
@@ -0,0 +1,27 @@
1
+ import pytest
2
+
3
+ from tradedangerous import utils
4
+ from tradedangerous import TradeEnv
5
+
6
+
7
+ class TestUtils(object):
8
+ # TODO: Test 'von' etc.
9
+
10
+ def test_titleFixup_s(self):
11
+ assert "Smith's" == utils.titleFixup("smith's")
12
+
13
+ def test_titleFixup_mc(self):
14
+ assert 'McDonald' == utils.titleFixup('mcdonald')
15
+ assert 'McKilroy' == utils.titleFixup('mckilroy')
16
+
17
+ def test_titleFixup_mac(self):
18
+ assert 'MacNair' == utils.titleFixup('macnair')
19
+ # Needs to be > 3 characters after Mac
20
+ assert 'Macnai' == utils.titleFixup('macnai')
21
+
22
+
23
+ def test_checkForOcrDerp(self, capsys):
24
+ tdenv = TradeEnv()
25
+ utils.checkForOcrDerp(tdenv, 'some', 'Aquire0')
26
+ captured = capsys.readouterr()
27
+ assert "Ignoring 'some/Aquire0' because it looks like OCR derp." in captured.out
@@ -285,12 +285,12 @@ def getStationByNameIndex(cur):
285
285
  """ Build station index in STAR/Station notation """
286
286
  cur.execute("""
287
287
  SELECT station_id,
288
- UPPER(system.name) || '/' || UPPER(station.name)
288
+ system.name || '/' || station.name
289
289
  FROM System
290
290
  INNER JOIN Station
291
291
  USING (system_id)
292
292
  """)
293
- return { name: ID for (ID, name) in cur }
293
+ return { name.upper(): ID for (ID, name) in cur }
294
294
 
295
295
 
296
296
  def getItemByNameIndex(cur):