小编Tho*_*ohn的帖子

文件在Enzyme上传测试

我的渲染功能中有一个FileInput

      <FileInput
      accept= "image/jpeg,image/png,audio/mp3"
      onChange= {this.fileInputOnChange}
      children= {<i className="fa fa-paperclip"/>}
      className= 'fileInput'
      />
Run Code Online (Sandbox Code Playgroud)

我需要编写一个文件上传测试,当我模拟更改函数时,它调用函数fileInputOnChange

fileInputOnChange: function(evt){
var file = evt.target.files[0];
var fileReader = new FileReader();

fileReader.onload = function(readFile){
  // Check the file type.
  var fileType = file.type.toLowerCase();

  if(fileType.lastIndexOf('image') === 0 && (fileType.lastIndexOf('png') >= 0 || fileType.lastIndexOf('jpeg'))){
    var image = new Image();

    image.onload = function(){
      var attachedFile = {
        attached: file,
        mediaSource: readFile.target.result,
        type: 'image'
      } 
        this.props.onChange(attachedFile);
    }.bind(this);

    image.onerror = function(){
      this.props.onError("INVALID_TYPE");
    }.bind(this);

    image.src = readFile.target.result;
  }else if(fileType.lastIndexOf('audio') === 0 && …
Run Code Online (Sandbox Code Playgroud)

mocha.js sinon chai reactjs enzyme

13
推荐指数
1
解决办法
6746
查看次数

模拟onClick不在酶中工作

这是一个取消按钮

<div className="cancelFileBtn" onClick={this.props.cancelFileSending}>
Run Code Online (Sandbox Code Playgroud)

我需要模拟它的点击,我尝试了以下测试

wrapper.find('.cancelFileBtn').simulate('click');
Run Code Online (Sandbox Code Playgroud)

但点击功能仍未定义......我是否还错过了其他任何内容?如果有人在模拟中存在任何变化,那将会非常有帮助

<SendMessageButton onClick={this.props.handleClickSendMessage} loadingFile={this.props.loadingFile}/>
Run Code Online (Sandbox Code Playgroud)

mocha.js chai reactjs enzyme

11
推荐指数
1
解决办法
5893
查看次数

Django芹菜任务在单独的服务器上

我们有两台服务器,服务器A和服务器B.服务器A专用于运行django Web应用程序.由于大量数据,我们决定在服务器B中运行芹菜任务.服务器A和B使用公共数据库.在服务器A,webapp的模型中保存后保存任务.如何在我的django项目中使用rabbitmq实现这个想法

django rabbitmq celery

6
推荐指数
1
解决办法
935
查看次数

如何在反应组分的酶中设置对象类型道具值?

我尝试了两种方法,

1.

const wrapper=shallow(<ActiveConversation />)
wrapper.setProps({activeConversation:c,agent:a});
expect(wrapper.prop('messagesList')).to.equal(messagesList);
Run Code Online (Sandbox Code Playgroud)

2.

const wrapper=shallow(<ActiveConversation messagesList={messagesList}
       agent={agent} contactFormState={d} tagSuggestions={t}/>);
Run Code Online (Sandbox Code Playgroud)

但是这两个道具仍未定义

reactjs enzyme

5
推荐指数
0
解决办法
1154
查看次数

cassandra中主键上的模式匹配“喜欢”

在卡桑德拉 'like'可用于在 SASI 索引列上查找满足搜索模式的匹配结果,它运行良好,但如何在主键上使用 like。

这是我的桌子:

CREATE TABLE indexxx (
    title VARCHAR,
    PRIMARY KEY (title));
Run Code Online (Sandbox Code Playgroud)

主键上不允许索引

CREATE CUSTOM INDEX testtt ON indexxx (title) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'mode': 'CONTAINS', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer', 'case_sensitive': 'false'};



InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot create secondary index on partition key column title"
Run Code Online (Sandbox Code Playgroud)

当尝试在没有 sasi 索引的情况下使用 like 时,

select * from indexxx  where title like '%kkk%' ;

InvalidRequest: Error from server: code=2200 [Invalid query] message="LIKE restriction is only supported on properly …
Run Code Online (Sandbox Code Playgroud)

cql cassandra nosql cql3 cassandra-3.0

3
推荐指数
1
解决办法
4162
查看次数

无法安装 Python argon2_cffi

我正在尝试在不使用 pip 的情况下在我的 python 3.5 虚拟环境中安装 argon2_cffi。我已经从github下载了这个包。当我尝试安装它时,

python setup.py build 或 install,它失败并出现错误

running install
running bdist_egg
running egg_info
creating src/argon2_cffi.egg-info
writing requirements to src/argon2_cffi.egg-info/requires.txt
writing src/argon2_cffi.egg-info/PKG-INFO
writing dependency_links to src/argon2_cffi.egg-
info/dependency_links.txt
writing top-level names to src/argon2_cffi.egg-info/top_level.txt
writing manifest file 'src/argon2_cffi.egg-info/SOURCES.txt'
reading manifest file 'src/argon2_cffi.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files found matching 'src/argon2/_ffi.py'
warning: no previously-included files found matching '.gitmodules'
warning: no previously-included files found matching 'extras/libargon2/.git'
warning: no previously-included files found matching 'appveyor.yml'
warning: …
Run Code Online (Sandbox Code Playgroud)

python pip python-3.x argon2-ffi

2
推荐指数
1
解决办法
2446
查看次数

Python中列表的最大列表

我需要找到列表中所有索引项的最大值,这是有效的方法,numpy有任何函数或高效和最好的pythonic方式,我的列表元素将长度超过100,每个列表有20个元素.

例如:

[[1,2,3,4,5,6],[3,2,1,4,5,6],[4,3,2,1,5,6],[1,1,1,1,1,1]]
max_list = [4,3,3,4,5,6]
Run Code Online (Sandbox Code Playgroud)

我的列表将长度大约为100,每个内部列表包含20个元素

python arrays numpy

1
推荐指数
1
解决办法
2427
查看次数