Datagenerator.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>DataGenerator &mdash; baangt 1.1.1 documentation</title>
  8. <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  9. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  10. <script type="text/javascript" src="_static/jquery.js"></script>
  11. <script type="text/javascript" src="_static/underscore.js"></script>
  12. <script type="text/javascript" src="_static/doctools.js"></script>
  13. <script type="text/javascript" src="_static/language_data.js"></script>
  14. <script type="text/javascript" src="_static/js/theme.js"></script>
  15. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  16. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  17. <link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
  18. <link rel="index" title="Index" href="genindex.html" />
  19. <link rel="search" title="Search" href="search.html" />
  20. <link rel="next" title="Developer guidelines for custom enhancements" href="Developer.html" />
  21. <link rel="prev" title="SendStatistics" href="SendStatistics.html" />
  22. </head>
  23. <body class="wy-body-for-nav">
  24. <div class="wy-grid-for-nav">
  25. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  26. <div class="wy-side-scroll">
  27. <div class="wy-side-nav-search" >
  28. <a href="index.html" class="icon icon-home"> baangt
  29. </a>
  30. <div role="search">
  31. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  32. <input type="text" name="q" placeholder="Search docs" />
  33. <input type="hidden" name="check_keywords" value="yes" />
  34. <input type="hidden" name="area" value="default" />
  35. </form>
  36. </div>
  37. </div>
  38. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  39. <p class="caption"><span class="caption-text">Contents:</span></p>
  40. <ul class="current">
  41. <li class="toctree-l1"><a class="reference internal" href="Installation.html"> Installation</a></li>
  42. <li class="toctree-l1"><a class="reference internal" href="OverviewUsage.html"> Overview</a></li>
  43. <li class="toctree-l1"><a class="reference internal" href="simpleExample.html"> First Steps</a></li>
  44. <li class="toctree-l1"><a class="reference internal" href="Structure.html"> Structure</a></li>
  45. <li class="toctree-l1"><a class="reference internal" href="ParametersConfigFile.html"> Parameters</a></li>
  46. <li class="toctree-l1"><a class="reference internal" href="SimpleAPI.html"> First API Test</a></li>
  47. <li class="toctree-l1"><a class="reference internal" href="TestTypes.html"> Types of Tests</a></li>
  48. <li class="toctree-l1"><a class="reference internal" href="DataFile.html"> Data file</a></li>
  49. <li class="toctree-l1"><a class="reference internal" href="SaveResults2Database.html"> Results in Database</a></li>
  50. <li class="toctree-l1"><a class="reference internal" href="HistoryAndReasons.html"> History</a></li>
  51. <li class="toctree-l1"><a class="reference internal" href="contributors.html"> Contributions</a></li>
  52. <li class="toctree-l1"><a class="reference internal" href="changelog.html"> Changelog</a></li>
  53. <li class="toctree-l1"><a class="reference internal" href="PlannedFeatures.html"> Planned Features</a></li>
  54. <li class="toctree-l1"><a class="reference internal" href="BrowserDrivers.html"> Browser Drivers</a></li>
  55. <li class="toctree-l1"><a class="reference internal" href="Variables.html"> Variables</a></li>
  56. <li class="toctree-l1"><a class="reference internal" href="SendStatistics.html"> Results</a></li>
  57. <li class="toctree-l1 current"><a class="current reference internal" href="#">DataGenerator</a></li>
  58. <li class="toctree-l1"><a class="reference internal" href="#input-file">Input File</a></li>
  59. <li class="toctree-l1"><a class="reference internal" href="#data-type">Data Type</a></li>
  60. <li class="toctree-l1"><a class="reference internal" href="#all-data-types-format">All Data Types Format</a></li>
  61. <li class="toctree-l1"><a class="reference internal" href="Developer.html"> For Developers</a></li>
  62. <li class="toctree-l1"><a class="reference internal" href="baangt-Plugin.html">What is a baangt-plugin</a></li>
  63. <li class="toctree-l1"><a class="reference internal" href="baangt-Plugin.html#how-to-make-a-baangt-plugin">how to make a baangt-plugin</a></li>
  64. <li class="toctree-l1"><a class="reference internal" href="baangt-Plugin.html#how-the-baangt-plugin-work">how the baangt-plugin work</a></li>
  65. <li class="toctree-l1"><a class="reference internal" href="baangt-Plugin.html#how-to-replace-the-existing-plugin-by-your-own-one">how to replace the existing plugin by your own one</a></li>
  66. <li class="toctree-l1"><a class="reference internal" href="articles/Articles.html"> :subheader: Articles</a></li>
  67. <li class="toctree-l1"><a class="reference external" href="http://www.baangt.org"> Web</a></li>
  68. </ul>
  69. <p class="caption"><span class="caption-text">Autodocs:</span></p>
  70. <ul>
  71. <li class="toctree-l1"><a class="reference internal" href="docs/baangt.base.html">Autodocs</a></li>
  72. <li class="toctree-l1"><a class="reference internal" href="docs/modules.html">Modules</a></li>
  73. </ul>
  74. </div>
  75. </div>
  76. </nav>
  77. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  78. <nav class="wy-nav-top" aria-label="top navigation">
  79. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  80. <a href="index.html">baangt</a>
  81. </nav>
  82. <div class="wy-nav-content">
  83. <div class="rst-content">
  84. <div role="navigation" aria-label="breadcrumbs navigation">
  85. <ul class="wy-breadcrumbs">
  86. <li><a href="index.html">Docs</a> &raquo;</li>
  87. <li>DataGenerator</li>
  88. <li class="wy-breadcrumbs-aside">
  89. <a href="_sources/Datagenerator.rst.txt" rel="nofollow"> View page source</a>
  90. </li>
  91. </ul>
  92. <hr/>
  93. </div>
  94. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  95. <div itemprop="articleBody">
  96. <div class="section" id="datagenerator">
  97. <h1>DataGenerator<a class="headerlink" href="#datagenerator" title="Permalink to this headline">¶</a></h1>
  98. <p>When we work with <code class="docutils literal notranslate"><span class="pre">baangt</span></code> to perform various tasks, we need to give excel file containing all data as input.
  99. Sometimes this data can be too big and can be a huge headache when one has to type all these manually. To overcome this
  100. issue we had made an application which can generate all possible data combinations by just providing and small excel file
  101. containing all data.</p>
  102. </div>
  103. <div class="section" id="input-file">
  104. <h1>Input File<a class="headerlink" href="#input-file" title="Permalink to this headline">¶</a></h1>
  105. <img alt="_images/DataGeneratorInput.png" src="_images/DataGeneratorInput.png" />
  106. <dl class="simple">
  107. <dt>This image is an example input file. Different types of data types supported are given different number in the above image.</dt><dd><ol class="arabic simple">
  108. <li><p>Is a simple value.</p></li>
  109. <li><p>Is a list of value.</p></li>
  110. <li><p>Is a list of value with <code class="docutils literal notranslate"><span class="pre">RND_</span></code> prefix. We will learn more on it further.</p></li>
  111. <li><p><code class="docutils literal notranslate"><span class="pre">RND_1,10,2</span></code>: <code class="docutils literal notranslate"><span class="pre">RND_</span></code> prefix is also used here but with a range.</p></li>
  112. <li><p>Simple range.</p></li>
  113. <li><p>List of header.</p></li>
  114. <li><p><code class="docutils literal notranslate"><span class="pre">FKR_</span></code> prefix is used here.</p></li>
  115. <li><p><code class="docutils literal notranslate"><span class="pre">FKR_</span></code> prefix is used here with a new integer value 0 in end.</p></li>
  116. <li><p><code class="docutils literal notranslate"><span class="pre">RRD_</span></code> prefix is used here.</p></li>
  117. </ol>
  118. </dd>
  119. </dl>
  120. <p>Using these data type we will generate all possible values.
  121. Here is a simple example with simple value and value of list.</p>
  122. <p>Example Input:-</p>
  123. <p>vehicle, seats
  124. car, [2,4,5]
  125. bus, 60</p>
  126. <p>Example Output:-</p>
  127. <p>vehicle, seats
  128. car, 2
  129. car, 4
  130. car, 5
  131. bus, 60</p>
  132. <p>As you can see that the output file contains every possible combination of input file. Further you will learn more about
  133. Data Types in next section.</p>
  134. </div>
  135. <div class="section" id="data-type">
  136. <h1>Data Type<a class="headerlink" href="#data-type" title="Permalink to this headline">¶</a></h1>
  137. <dl class="simple">
  138. <dt>We will use the reference of above image and assigned number to learn about it in detail.</dt><dd><ol class="arabic simple">
  139. <li><p>It is a simple single value.</p></li>
  140. <li><p>It is a list of values which will be further used to create all possible combinations as shown in above example. Format = [value1, value2, value3]</p></li>
  141. <li><p>Here comes a prefix. <code class="docutils literal notranslate"><span class="pre">RND_</span></code> is a prefix which is used when we don’t need to create all possible combinations from a list
  142. and have to use any one of the data from the list whenever new data is generated. So it will not increase number as it
  143. is not compulsory to use all value.</p></li>
  144. <li><p>Range is a new data type. It is used when we want to create a list of number with all of them having same gap between
  145. them.
  146. Format = Starting-Ending,Step
  147. Example input = 2-40,4 || Output = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]
  148. As shown in example, instead of writing whole list we can just use Range. In our example range is used with <code class="docutils literal notranslate"><span class="pre">RND_</span></code> so
  149. after creating this list random function will come into effect.</p></li>
  150. <li><p>As explained in point 4.</p></li>
  151. <li><p>List of header. When there are multiple headers which have same value inside them, then we can simply write a list of
  152. header in a single cell. Then the program will consider each value as an individual header and each of them will have
  153. the same below data.
  154. Example:
  155. header1, [header2,header3]
  156. value1 , value2
  157. output:
  158. header1, header2, header3
  159. value1 , value2 , value2</p></li>
  160. <li><p><code class="docutils literal notranslate"><span class="pre">FKR_</span></code> is another prefix used to generate fake data. It uses the faker module of python the generate the fake data.
  161. format = <code class="docutils literal notranslate"><span class="pre">FKR_``(type,</span> <span class="pre">locale)</span>
  162. <span class="pre">Note:-</span> <span class="pre">We</span> <span class="pre">use</span> <span class="pre">tuple</span> <span class="pre">with</span> <span class="pre">``FKR_</span></code> prefix
  163. Example = <code class="docutils literal notranslate"><span class="pre">FKR_(email,</span> <span class="pre">EN_US)</span></code>
  164. In our example we used type = email as we want to get fake emails. EN_US is a locale which will make sure that email
  165. should be of same words of that language. By default this will create list of 5 fake emails, if you want to change default
  166. number of 5 you can add that number in the end of tuple.
  167. Example:- <code class="docutils literal notranslate"><span class="pre">FKR_(email,</span> <span class="pre">EN_US,</span> <span class="pre">8)</span></code>
  168. Now this will generate list of 8 fake email and on every data any random email would be selected.</p></li>
  169. <li><p>Now what if we don’t want to create a list of email instead we want new mail for every data generated. For this we can
  170. simply use 0 number at the position of list length.
  171. Example:- <code class="docutils literal notranslate"><span class="pre">FKR_(email,</span> <span class="pre">EN_US,</span> <span class="pre">0)</span></code>
  172. Now this will generate new email for every data in the output.</p></li>
  173. <li><p><code class="docutils literal notranslate"><span class="pre">RRD_</span></code> is used when we have multiple sheets in a input file and we need to take value which are matching conditions
  174. from that sheet.
  175. Format:- <code class="docutils literal notranslate"><span class="pre">RRD_(&lt;sheetName&gt;,&lt;TargetData&gt;,[Header1:[Value1],Header2:[Value1,Value2]])</span></code>
  176. Here sheetName is the name of the sheet where our TargetData is located. A dictionary of TargetData is generated with all
  177. the data which are matching from our Header: Value pair. A header with multiple value list is than converted to all
  178. possible value as mentioned in above explanation. At last a random value is selected from TargetData dictionary for every
  179. output data.
  180. If TargetData = <code class="docutils literal notranslate"><span class="pre">*</span></code> then all the values of the matched row will be treated as TargetData.
  181. If Header:Value List = <code class="docutils literal notranslate"><span class="pre">[]</span></code> then the defined TargetData will be collected from every row of the defined sheet.
  182. i.e.
  183. For all value in matching row <code class="docutils literal notranslate"><span class="pre">RRD_(sheetName,*,[Header1:[Value1],Header2:[Value1,Value2]])</span></code>
  184. For TargetData from whole Sheet <code class="docutils literal notranslate"><span class="pre">RRD_(sheetName,TargetData,[])</span></code>
  185. For all data inside sheet <code class="docutils literal notranslate"><span class="pre">RRD_(sheetName,*,[])</span></code>
  186. If a input sheet has multiple cells using <code class="docutils literal notranslate"><span class="pre">RRD_</span></code> prefix with a matching data (=header of excel column) in TargetData
  187. then they will be treated as one unit. In the output file there will be only one column of that matching header and while
  188. selecting random data only the rows which have same value of that header will be considered.
  189. i.e. First <code class="docutils literal notranslate"><span class="pre">RRD_</span></code> cell has value “x” for the header while selected randomly, then the second cell will select data
  190. randomly only from the rows which have “x” value for the same header.</p></li>
  191. </ol>
  192. </dd>
  193. </dl>
  194. </div>
  195. <div class="section" id="all-data-types-format">
  196. <h1>All Data Types Format<a class="headerlink" href="#all-data-types-format" title="Permalink to this headline">¶</a></h1>
  197. <ol class="arabic simple">
  198. <li><p>Value = <code class="docutils literal notranslate"><span class="pre">&lt;value&gt;</span></code></p></li>
  199. <li><p>list of values = <code class="docutils literal notranslate"><span class="pre">[&lt;value1&gt;,&lt;value2&gt;]</span></code></p></li>
  200. <li><p>range = <code class="docutils literal notranslate"><span class="pre">&lt;start&gt;-&lt;end&gt;,&lt;step&gt;</span></code></p></li>
  201. <li><p>random = <code class="docutils literal notranslate"><span class="pre">RND_[list]</span></code></p></li>
  202. <li><p>random from range = <code class="docutils literal notranslate"><span class="pre">RND_&lt;start&gt;-&lt;end&gt;,&lt;step&gt;</span></code></p></li>
  203. <li><p>List of header = <code class="docutils literal notranslate"><span class="pre">[&lt;title1&gt;,</span> <span class="pre">&lt;title2&gt;,</span> <span class="pre">&lt;title3&gt;]</span></code></p></li>
  204. <li><p>Faker Prefix = <code class="docutils literal notranslate"><span class="pre">FKR_(&lt;type&gt;,</span> <span class="pre">&lt;locale&gt;,</span> <span class="pre">&lt;number_of_data&gt;)</span></code></p></li>
  205. <li><p>RRD Prefix = <code class="docutils literal notranslate"><span class="pre">RRD_(&lt;sheetName&gt;,&lt;TargetData&gt;,[&lt;Header1&gt;:[&lt;Value1&gt;],&lt;Header2&gt;:[&lt;Value1&gt;,&lt;Value2&gt;]])</span></code></p></li>
  206. </ol>
  207. </div>
  208. </div>
  209. </div>
  210. <footer>
  211. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  212. <a href="Developer.html" class="btn btn-neutral float-right" title="Developer guidelines for custom enhancements" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
  213. <a href="SendStatistics.html" class="btn btn-neutral float-left" title="SendStatistics" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  214. </div>
  215. <hr/>
  216. <div role="contentinfo">
  217. <p>
  218. &copy; Copyright 2020, Bernhard Buhl
  219. </p>
  220. </div>
  221. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  222. </footer>
  223. </div>
  224. </div>
  225. </section>
  226. </div>
  227. <script type="text/javascript">
  228. jQuery(function () {
  229. SphinxRtdTheme.Navigation.enable(true);
  230. });
  231. </script>
  232. </body>
  233. </html>