test_var_operations.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. """Integration tests for var operations."""
  2. from typing import Generator
  3. import pytest
  4. from selenium.webdriver.common.by import By
  5. from reflex.testing import AppHarness
  6. # pyright: reportOptionalMemberAccess=false, reportGeneralTypeIssues=false, reportUnknownMemberType=false
  7. def VarOperations():
  8. """App with var operations."""
  9. import reflex as rx
  10. class VarOperationState(rx.State):
  11. int_var1: int = 10
  12. int_var2: int = 5
  13. int_var3: int = 7
  14. float_var1: float = 10.5
  15. float_var2: float = 5.5
  16. list1: list = [1, 2]
  17. list2: list = [3, 4]
  18. str_var1: str = "first"
  19. str_var2: str = "second"
  20. dict1: dict = {1: 2}
  21. dict2: dict = {3: 4}
  22. @rx.var
  23. def token(self) -> str:
  24. return self.get_token()
  25. app = rx.App(state=VarOperationState)
  26. @app.add_page
  27. def index():
  28. return rx.vstack(
  29. rx.input(id="token", value=VarOperationState.token, is_read_only=True),
  30. # INT INT
  31. rx.text(
  32. VarOperationState.int_var1 + VarOperationState.int_var2,
  33. id="int_add_int",
  34. ),
  35. rx.text(
  36. VarOperationState.int_var1 * VarOperationState.int_var2,
  37. id="int_mult_int",
  38. ),
  39. rx.text(
  40. VarOperationState.int_var1 - VarOperationState.int_var2,
  41. id="int_sub_int",
  42. ),
  43. rx.text(
  44. VarOperationState.int_var1**VarOperationState.int_var2,
  45. id="int_exp_int",
  46. ),
  47. rx.text(
  48. VarOperationState.int_var1 / VarOperationState.int_var2,
  49. id="int_div_int",
  50. ),
  51. rx.text(
  52. VarOperationState.int_var1 // VarOperationState.int_var3,
  53. id="int_floor_int",
  54. ),
  55. rx.text(
  56. VarOperationState.int_var1 % VarOperationState.int_var2,
  57. id="int_mod_int",
  58. ),
  59. rx.text(
  60. VarOperationState.int_var1 | VarOperationState.int_var2,
  61. id="int_or_int",
  62. ),
  63. rx.text(
  64. (VarOperationState.int_var1 > VarOperationState.int_var2).to_string(),
  65. id="int_gt_int",
  66. ),
  67. rx.text(
  68. (VarOperationState.int_var1 < VarOperationState.int_var2).to_string(),
  69. id="int_lt_int",
  70. ),
  71. rx.text(
  72. (VarOperationState.int_var1 >= VarOperationState.int_var2).to_string(),
  73. id="int_gte_int",
  74. ),
  75. rx.text(
  76. (VarOperationState.int_var1 <= VarOperationState.int_var2).to_string(),
  77. id="int_lte_int",
  78. ),
  79. rx.text(
  80. VarOperationState.int_var1 & VarOperationState.int_var2,
  81. id="int_and_int",
  82. ),
  83. rx.text(
  84. (VarOperationState.int_var1 | VarOperationState.int_var2).to_string(),
  85. id="int_or_int",
  86. ),
  87. rx.text(
  88. (VarOperationState.int_var1 == VarOperationState.int_var2).to_string(),
  89. id="int_eq_int",
  90. ),
  91. rx.text(
  92. (VarOperationState.int_var1 != VarOperationState.int_var2).to_string(),
  93. id="int_neq_int",
  94. ),
  95. # INT FLOAT OR FLOAT INT
  96. rx.text(
  97. VarOperationState.float_var1 + VarOperationState.int_var2,
  98. id="float_add_int",
  99. ),
  100. rx.text(
  101. VarOperationState.float_var1 * VarOperationState.int_var2,
  102. id="float_mult_int",
  103. ),
  104. rx.text(
  105. VarOperationState.float_var1 - VarOperationState.int_var2,
  106. id="float_sub_int",
  107. ),
  108. rx.text(
  109. VarOperationState.float_var1**VarOperationState.int_var2,
  110. id="float_exp_int",
  111. ),
  112. rx.text(
  113. VarOperationState.float_var1 / VarOperationState.int_var2,
  114. id="float_div_int",
  115. ),
  116. rx.text(
  117. VarOperationState.float_var1 // VarOperationState.int_var3,
  118. id="float_floor_int",
  119. ),
  120. rx.text(
  121. VarOperationState.float_var1 % VarOperationState.int_var2,
  122. id="float_mod_int",
  123. ),
  124. rx.text(
  125. (VarOperationState.float_var1 > VarOperationState.int_var2).to_string(),
  126. id="float_gt_int",
  127. ),
  128. rx.text(
  129. (VarOperationState.float_var1 < VarOperationState.int_var2).to_string(),
  130. id="float_lt_int",
  131. ),
  132. rx.text(
  133. (
  134. VarOperationState.float_var1 >= VarOperationState.int_var2
  135. ).to_string(),
  136. id="float_gte_int",
  137. ),
  138. rx.text(
  139. (
  140. VarOperationState.float_var1 <= VarOperationState.int_var2
  141. ).to_string(),
  142. id="float_lte_int",
  143. ),
  144. rx.text(
  145. (
  146. VarOperationState.float_var1 == VarOperationState.int_var2
  147. ).to_string(),
  148. id="float_eq_int",
  149. ),
  150. rx.text(
  151. (
  152. VarOperationState.float_var1 != VarOperationState.int_var2
  153. ).to_string(),
  154. id="float_neq_int",
  155. ),
  156. rx.text(
  157. (VarOperationState.float_var1 & VarOperationState.int_var2).to_string(),
  158. id="float_and_int",
  159. ),
  160. rx.text(
  161. (VarOperationState.float_var1 | VarOperationState.int_var2).to_string(),
  162. id="float_or_int",
  163. ),
  164. # INT, DICT
  165. rx.text(
  166. (VarOperationState.int_var1 | VarOperationState.dict1).to_string(),
  167. id="int_or_dict",
  168. ),
  169. rx.text(
  170. (VarOperationState.int_var1 & VarOperationState.dict1).to_string(),
  171. id="int_and_dict",
  172. ),
  173. rx.text(
  174. (VarOperationState.int_var1 == VarOperationState.dict1).to_string(),
  175. id="int_eq_dict",
  176. ),
  177. rx.text(
  178. (VarOperationState.int_var1 != VarOperationState.dict1).to_string(),
  179. id="int_neq_dict",
  180. ),
  181. # FLOAT FLOAT
  182. rx.text(
  183. VarOperationState.float_var1 + VarOperationState.float_var2,
  184. id="float_add_float",
  185. ),
  186. rx.text(
  187. VarOperationState.float_var1 * VarOperationState.float_var2,
  188. id="float_mult_float",
  189. ),
  190. rx.text(
  191. VarOperationState.float_var1 - VarOperationState.float_var2,
  192. id="float_sub_float",
  193. ),
  194. rx.text(
  195. VarOperationState.float_var1**VarOperationState.float_var2,
  196. id="float_exp_float",
  197. ),
  198. rx.text(
  199. VarOperationState.float_var1 / VarOperationState.float_var2,
  200. id="float_div_float",
  201. ),
  202. rx.text(
  203. VarOperationState.float_var1 // VarOperationState.float_var2,
  204. id="float_floor_float",
  205. ),
  206. rx.text(
  207. VarOperationState.float_var1 % VarOperationState.float_var2,
  208. id="float_mod_float",
  209. ),
  210. rx.text(
  211. (
  212. VarOperationState.float_var1 > VarOperationState.float_var2
  213. ).to_string(),
  214. id="float_gt_float",
  215. ),
  216. rx.text(
  217. (
  218. VarOperationState.float_var1 < VarOperationState.float_var2
  219. ).to_string(),
  220. id="float_lt_float",
  221. ),
  222. rx.text(
  223. (
  224. VarOperationState.float_var1 >= VarOperationState.float_var2
  225. ).to_string(),
  226. id="float_gte_float",
  227. ),
  228. rx.text(
  229. (
  230. VarOperationState.float_var1 <= VarOperationState.float_var2
  231. ).to_string(),
  232. id="float_lte_float",
  233. ),
  234. rx.text(
  235. (
  236. VarOperationState.float_var1 == VarOperationState.float_var2
  237. ).to_string(),
  238. id="float_eq_float",
  239. ),
  240. rx.text(
  241. (
  242. VarOperationState.float_var1 != VarOperationState.float_var2
  243. ).to_string(),
  244. id="float_neq_float",
  245. ),
  246. rx.text(
  247. (
  248. VarOperationState.float_var1 & VarOperationState.float_var2
  249. ).to_string(),
  250. id="float_and_float",
  251. ),
  252. rx.text(
  253. (
  254. VarOperationState.float_var1 | VarOperationState.float_var2
  255. ).to_string(),
  256. id="float_or_float",
  257. ),
  258. # FLOAT STR
  259. rx.text(
  260. VarOperationState.float_var1 | VarOperationState.str_var1,
  261. id="float_or_str",
  262. ),
  263. rx.text(
  264. VarOperationState.float_var1 & VarOperationState.str_var1,
  265. id="float_and_str",
  266. ),
  267. rx.text(
  268. (
  269. VarOperationState.float_var1 == VarOperationState.str_var1
  270. ).to_string(),
  271. id="float_eq_str",
  272. ),
  273. rx.text(
  274. (
  275. VarOperationState.float_var1 != VarOperationState.str_var1
  276. ).to_string(),
  277. id="float_neq_str",
  278. ),
  279. # FLOAT LIST
  280. rx.text(
  281. (VarOperationState.float_var1 | VarOperationState.list1).to_string(),
  282. id="float_or_list",
  283. ),
  284. rx.text(
  285. (VarOperationState.float_var1 & VarOperationState.list1).to_string(),
  286. id="float_and_list",
  287. ),
  288. rx.text(
  289. (VarOperationState.float_var1 == VarOperationState.list1).to_string(),
  290. id="float_eq_list",
  291. ),
  292. rx.text(
  293. (VarOperationState.float_var1 != VarOperationState.list1).to_string(),
  294. id="float_neq_list",
  295. ),
  296. # FLOAT DICT
  297. rx.text(
  298. (VarOperationState.float_var1 | VarOperationState.dict1).to_string(),
  299. id="float_or_dict",
  300. ),
  301. rx.text(
  302. (VarOperationState.float_var1 & VarOperationState.dict1).to_string(),
  303. id="float_and_dict",
  304. ),
  305. rx.text(
  306. (VarOperationState.float_var1 == VarOperationState.dict1).to_string(),
  307. id="float_eq_dict",
  308. ),
  309. rx.text(
  310. (VarOperationState.float_var1 != VarOperationState.dict1).to_string(),
  311. id="float_neq_dict",
  312. ),
  313. # STR STR
  314. rx.text(
  315. VarOperationState.str_var1 + VarOperationState.str_var2,
  316. id="str_add_str",
  317. ),
  318. rx.text(
  319. (VarOperationState.str_var1 > VarOperationState.str_var2).to_string(),
  320. id="str_gt_str",
  321. ),
  322. rx.text(
  323. (VarOperationState.str_var1 < VarOperationState.str_var2).to_string(),
  324. id="str_lt_str",
  325. ),
  326. rx.text(
  327. (VarOperationState.str_var1 >= VarOperationState.str_var2).to_string(),
  328. id="str_gte_str",
  329. ),
  330. rx.text(
  331. (VarOperationState.str_var1 <= VarOperationState.str_var2).to_string(),
  332. id="str_lte_str",
  333. ),
  334. rx.text(
  335. (
  336. VarOperationState.float_var1 == VarOperationState.float_var2
  337. ).to_string(),
  338. id="str_eq_str",
  339. ),
  340. rx.text(
  341. (
  342. VarOperationState.float_var1 != VarOperationState.float_var2
  343. ).to_string(),
  344. id="str_neq_str",
  345. ),
  346. rx.text(
  347. VarOperationState.str_var1.contains("fir").to_string(),
  348. id="str_contains",
  349. ),
  350. rx.text(
  351. VarOperationState.str_var1 | VarOperationState.str_var1, id="str_or_str"
  352. ),
  353. rx.text(
  354. VarOperationState.str_var1 & VarOperationState.str_var2,
  355. id="str_and_str",
  356. ),
  357. # STR, INT
  358. rx.text(
  359. VarOperationState.str_var1 * VarOperationState.int_var2,
  360. id="str_mult_int",
  361. ),
  362. rx.text(
  363. VarOperationState.str_var1 & VarOperationState.int_var2,
  364. id="str_and_int",
  365. ),
  366. rx.text(
  367. VarOperationState.str_var1 | VarOperationState.int_var2, id="str_or_int"
  368. ),
  369. rx.text(
  370. (VarOperationState.str_var1 == VarOperationState.int_var1).to_string(),
  371. id="str_eq_int",
  372. ),
  373. rx.text(
  374. (VarOperationState.str_var1 != VarOperationState.int_var1).to_string(),
  375. id="str_neq_int",
  376. ),
  377. # STR, LIST
  378. rx.text(
  379. VarOperationState.str_var1 | VarOperationState.list1, id="str_or_list"
  380. ),
  381. rx.text(
  382. (VarOperationState.str_var1 & VarOperationState.list1).to_string(),
  383. id="str_and_list",
  384. ),
  385. rx.text(
  386. (VarOperationState.str_var1 == VarOperationState.list1).to_string(),
  387. id="str_eq_list",
  388. ),
  389. rx.text(
  390. (VarOperationState.str_var1 != VarOperationState.list1).to_string(),
  391. id="str_neq_list",
  392. ),
  393. # STR, DICT
  394. rx.text(
  395. VarOperationState.str_var1 | VarOperationState.dict1, id="str_or_dict"
  396. ),
  397. rx.text(
  398. (VarOperationState.str_var1 & VarOperationState.dict1).to_string(),
  399. id="str_and_dict",
  400. ),
  401. rx.text(
  402. (VarOperationState.str_var1 == VarOperationState.dict1).to_string(),
  403. id="str_eq_dict",
  404. ),
  405. rx.text(
  406. (VarOperationState.str_var1 != VarOperationState.dict1).to_string(),
  407. id="str_neq_dict",
  408. ),
  409. # LIST, LIST
  410. rx.text(
  411. (VarOperationState.list1 + VarOperationState.list2).to_string(),
  412. id="list_add_list",
  413. ),
  414. rx.text(
  415. (VarOperationState.list1 & VarOperationState.list2).to_string(),
  416. id="list_and_list",
  417. ),
  418. rx.text(
  419. (VarOperationState.list1 | VarOperationState.list2).to_string(),
  420. id="list_or_list",
  421. ),
  422. rx.text(
  423. (VarOperationState.list1 > VarOperationState.list2).to_string(),
  424. id="list_gt_list",
  425. ),
  426. rx.text(
  427. (VarOperationState.list1 < VarOperationState.list2).to_string(),
  428. id="list_lt_list",
  429. ),
  430. rx.text(
  431. (VarOperationState.list1 >= VarOperationState.list2).to_string(),
  432. id="list_gte_list",
  433. ),
  434. rx.text(
  435. (VarOperationState.list1 <= VarOperationState.list2).to_string(),
  436. id="list_lte_list",
  437. ),
  438. rx.text(
  439. (VarOperationState.list1 == VarOperationState.list2).to_string(),
  440. id="list_eq_list",
  441. ),
  442. rx.text(
  443. (VarOperationState.list1 != VarOperationState.list2).to_string(),
  444. id="list_neq_list",
  445. ),
  446. rx.text(
  447. VarOperationState.list1.contains(1).to_string(), id="list_contains"
  448. ),
  449. rx.text(VarOperationState.list1.reverse().to_string(), id="list_reverse"),
  450. # LIST, INT
  451. rx.text(
  452. (VarOperationState.list1 * VarOperationState.int_var2).to_string(),
  453. id="list_mult_int",
  454. ),
  455. rx.text(
  456. (VarOperationState.list1 | VarOperationState.int_var1).to_string(),
  457. id="list_or_int",
  458. ),
  459. rx.text(
  460. (VarOperationState.list1 & VarOperationState.int_var1).to_string(),
  461. id="list_and_int",
  462. ),
  463. rx.text(
  464. (VarOperationState.list1 == VarOperationState.int_var1).to_string(),
  465. id="list_eq_int",
  466. ),
  467. rx.text(
  468. (VarOperationState.list1 != VarOperationState.int_var1).to_string(),
  469. id="list_neq_int",
  470. ),
  471. # LIST, DICT
  472. rx.text(
  473. (VarOperationState.list1 | VarOperationState.dict1).to_string(),
  474. id="list_or_dict",
  475. ),
  476. rx.text(
  477. (VarOperationState.list1 & VarOperationState.dict1).to_string(),
  478. id="list_and_dict",
  479. ),
  480. rx.text(
  481. (VarOperationState.list1 == VarOperationState.dict1).to_string(),
  482. id="list_eq_dict",
  483. ),
  484. rx.text(
  485. (VarOperationState.list1 != VarOperationState.dict1).to_string(),
  486. id="list_neq_dict",
  487. ),
  488. # DICT, DICT
  489. rx.text(
  490. (VarOperationState.dict1 | VarOperationState.dict2).to_string(),
  491. id="dict_or_dict",
  492. ),
  493. rx.text(
  494. (VarOperationState.dict1 & VarOperationState.dict2).to_string(),
  495. id="dict_and_dict",
  496. ),
  497. rx.text(
  498. (VarOperationState.dict1 == VarOperationState.dict2).to_string(),
  499. id="dict_eq_dict",
  500. ),
  501. rx.text(
  502. (VarOperationState.dict1 != VarOperationState.dict2).to_string(),
  503. id="dict_neq_dict",
  504. ),
  505. rx.text(
  506. VarOperationState.dict1.contains(1).to_string(), id="dict_contains"
  507. ),
  508. )
  509. app.compile()
  510. @pytest.fixture(scope="session")
  511. def var_operations(tmp_path_factory) -> Generator[AppHarness, None, None]:
  512. """Start VarOperations app at tmp_path via AppHarness.
  513. Args:
  514. tmp_path_factory: pytest tmp_path_factory fixture
  515. Yields:
  516. running AppHarness instance
  517. """
  518. with AppHarness.create(
  519. root=tmp_path_factory.mktemp("var_operations"),
  520. app_source=VarOperations, # type: ignore
  521. ) as harness:
  522. assert harness.app_instance is not None, "app is not running"
  523. yield harness
  524. @pytest.fixture
  525. def driver(var_operations: AppHarness):
  526. """Get an instance of the browser open to the var operations app.
  527. Args:
  528. var_operations: harness for VarOperations app
  529. Yields:
  530. WebDriver instance.
  531. """
  532. driver = var_operations.frontend()
  533. try:
  534. token_input = driver.find_element(By.ID, "token")
  535. assert token_input
  536. # wait for the backend connection to send the token
  537. token = var_operations.poll_for_value(token_input)
  538. assert token is not None
  539. yield driver
  540. finally:
  541. driver.quit()
  542. def test_var_operations(driver, var_operations: AppHarness):
  543. """Test that the var operations produce the right results.
  544. Args:
  545. driver: selenium WebDriver open to the app
  546. var_operations: AppHarness for the var operations app
  547. """
  548. assert var_operations.app_instance is not None, "app is not running"
  549. # INT INT
  550. assert driver.find_element(By.ID, "int_add_int").text == "15"
  551. assert driver.find_element(By.ID, "int_mult_int").text == "50"
  552. assert driver.find_element(By.ID, "int_sub_int").text == "5"
  553. assert driver.find_element(By.ID, "int_exp_int").text == "100000"
  554. assert driver.find_element(By.ID, "int_div_int").text == "2"
  555. assert driver.find_element(By.ID, "int_floor_int").text == "1"
  556. assert driver.find_element(By.ID, "int_mod_int").text == "0"
  557. assert driver.find_element(By.ID, "int_gt_int").text == "true"
  558. assert driver.find_element(By.ID, "int_lt_int").text == "false"
  559. assert driver.find_element(By.ID, "int_gte_int").text == "true"
  560. assert driver.find_element(By.ID, "int_lte_int").text == "false"
  561. assert driver.find_element(By.ID, "int_and_int").text == "5"
  562. assert driver.find_element(By.ID, "int_or_int").text == "10"
  563. assert driver.find_element(By.ID, "int_eq_int").text == "false"
  564. assert driver.find_element(By.ID, "int_neq_int").text == "true"
  565. # INT FLOAT OR FLOAT INT
  566. assert driver.find_element(By.ID, "float_add_int").text == "15.5"
  567. assert driver.find_element(By.ID, "float_mult_int").text == "52.5"
  568. assert driver.find_element(By.ID, "float_sub_int").text == "5.5"
  569. assert driver.find_element(By.ID, "float_exp_int").text == "127628.15625"
  570. assert driver.find_element(By.ID, "float_div_int").text == "2.1"
  571. assert driver.find_element(By.ID, "float_floor_int").text == "1"
  572. assert driver.find_element(By.ID, "float_mod_int").text == "0.5"
  573. assert driver.find_element(By.ID, "float_gt_int").text == "true"
  574. assert driver.find_element(By.ID, "float_lt_int").text == "false"
  575. assert driver.find_element(By.ID, "float_gte_int").text == "true"
  576. assert driver.find_element(By.ID, "float_lte_int").text == "false"
  577. assert driver.find_element(By.ID, "float_eq_int").text == "false"
  578. assert driver.find_element(By.ID, "float_neq_int").text == "true"
  579. assert driver.find_element(By.ID, "float_and_int").text == "5"
  580. assert driver.find_element(By.ID, "float_or_int").text == "10.5"
  581. # INT, DICT
  582. assert driver.find_element(By.ID, "int_or_dict").text == "10"
  583. assert driver.find_element(By.ID, "int_and_dict").text == '{"1":2}'
  584. assert driver.find_element(By.ID, "int_eq_dict").text == "false"
  585. assert driver.find_element(By.ID, "int_neq_dict").text == "true"
  586. # FLOAT FLOAT
  587. assert driver.find_element(By.ID, "float_add_float").text == "16"
  588. assert driver.find_element(By.ID, "float_mult_float").text == "57.75"
  589. assert driver.find_element(By.ID, "float_sub_float").text == "5"
  590. assert driver.find_element(By.ID, "float_exp_float").text == "413562.49323606625"
  591. assert driver.find_element(By.ID, "float_div_float").text == "1.9090909090909092"
  592. assert driver.find_element(By.ID, "float_floor_float").text == "1"
  593. assert driver.find_element(By.ID, "float_mod_float").text == "5"
  594. assert driver.find_element(By.ID, "float_gt_float").text == "true"
  595. assert driver.find_element(By.ID, "float_lt_float").text == "false"
  596. assert driver.find_element(By.ID, "float_gte_float").text == "true"
  597. assert driver.find_element(By.ID, "float_lte_float").text == "false"
  598. assert driver.find_element(By.ID, "float_eq_float").text == "false"
  599. assert driver.find_element(By.ID, "float_neq_float").text == "true"
  600. assert driver.find_element(By.ID, "float_and_float").text == "5.5"
  601. assert driver.find_element(By.ID, "float_or_float").text == "10.5"
  602. # FLOAT STR
  603. assert driver.find_element(By.ID, "float_or_str").text == "10.5"
  604. assert driver.find_element(By.ID, "float_and_str").text == "first"
  605. assert driver.find_element(By.ID, "float_eq_str").text == "false"
  606. assert driver.find_element(By.ID, "float_neq_str").text == "true"
  607. # FLOAT,LIST
  608. assert driver.find_element(By.ID, "float_or_list").text == "10.5"
  609. assert driver.find_element(By.ID, "float_and_list").text == "[1,2]"
  610. assert driver.find_element(By.ID, "float_eq_list").text == "false"
  611. assert driver.find_element(By.ID, "float_neq_list").text == "true"
  612. # FLOAT, DICT
  613. assert driver.find_element(By.ID, "float_or_dict").text == "10.5"
  614. assert driver.find_element(By.ID, "float_and_dict").text == '{"1":2}'
  615. assert driver.find_element(By.ID, "float_eq_dict").text == "false"
  616. assert driver.find_element(By.ID, "float_neq_dict").text == "true"
  617. # STR STR
  618. assert driver.find_element(By.ID, "str_add_str").text == "firstsecond"
  619. assert driver.find_element(By.ID, "str_gt_str").text == "false"
  620. assert driver.find_element(By.ID, "str_lt_str").text == "true"
  621. assert driver.find_element(By.ID, "str_gte_str").text == "false"
  622. assert driver.find_element(By.ID, "str_lte_str").text == "true"
  623. assert driver.find_element(By.ID, "str_eq_str").text == "false"
  624. assert driver.find_element(By.ID, "str_neq_str").text == "true"
  625. assert driver.find_element(By.ID, "str_and_str").text == "second"
  626. assert driver.find_element(By.ID, "str_or_str").text == "first"
  627. assert driver.find_element(By.ID, "str_contains").text == "true"
  628. # STR INT
  629. assert (
  630. driver.find_element(By.ID, "str_mult_int").text == "firstfirstfirstfirstfirst"
  631. )
  632. assert driver.find_element(By.ID, "str_and_int").text == "5"
  633. assert driver.find_element(By.ID, "str_or_int").text == "first"
  634. assert driver.find_element(By.ID, "str_eq_int").text == "false"
  635. assert driver.find_element(By.ID, "str_neq_int").text == "true"
  636. # STR, LIST
  637. assert driver.find_element(By.ID, "str_and_list").text == "[1,2]"
  638. assert driver.find_element(By.ID, "str_or_list").text == "first"
  639. assert driver.find_element(By.ID, "str_eq_list").text == "false"
  640. assert driver.find_element(By.ID, "str_neq_list").text == "true"
  641. # STR, DICT
  642. assert driver.find_element(By.ID, "str_or_dict").text == "first"
  643. assert driver.find_element(By.ID, "str_and_dict").text == '{"1":2}'
  644. assert driver.find_element(By.ID, "str_eq_dict").text == "false"
  645. assert driver.find_element(By.ID, "str_neq_dict").text == "true"
  646. # LIST,LIST
  647. assert driver.find_element(By.ID, "list_add_list").text == "[1,2,3,4]"
  648. assert driver.find_element(By.ID, "list_gt_list").text == "false"
  649. assert driver.find_element(By.ID, "list_lt_list").text == "true"
  650. assert driver.find_element(By.ID, "list_gte_list").text == "false"
  651. assert driver.find_element(By.ID, "list_lte_list").text == "true"
  652. assert driver.find_element(By.ID, "list_eq_list").text == "false"
  653. assert driver.find_element(By.ID, "list_neq_list").text == "true"
  654. assert driver.find_element(By.ID, "list_and_list").text == "[3,4]"
  655. assert driver.find_element(By.ID, "list_or_list").text == "[1,2]"
  656. assert driver.find_element(By.ID, "list_contains").text == "true"
  657. assert driver.find_element(By.ID, "list_reverse").text == "[2,1]"
  658. # LIST INT
  659. assert driver.find_element(By.ID, "list_mult_int").text == "[1,2,1,2,1,2,1,2,1,2]"
  660. assert driver.find_element(By.ID, "list_or_int").text == "[1,2]"
  661. assert driver.find_element(By.ID, "list_and_int").text == "10"
  662. assert driver.find_element(By.ID, "list_eq_int").text == "false"
  663. assert driver.find_element(By.ID, "list_neq_int").text == "true"
  664. # LIST DICT
  665. assert driver.find_element(By.ID, "list_and_dict").text == '{"1":2}'
  666. assert driver.find_element(By.ID, "list_or_dict").text == "[1,2]"
  667. assert driver.find_element(By.ID, "list_eq_dict").text == "false"
  668. assert driver.find_element(By.ID, "list_neq_dict").text == "true"
  669. # DICT, DICT
  670. assert driver.find_element(By.ID, "dict_or_dict").text == '{"1":2}'
  671. assert driver.find_element(By.ID, "dict_and_dict").text == '{"3":4}'
  672. assert driver.find_element(By.ID, "dict_eq_dict").text == "false"
  673. assert driver.find_element(By.ID, "dict_neq_dict").text == "true"
  674. assert driver.find_element(By.ID, "dict_contains").text == "true"